package com.demo.mvc.iface.impl;

import java.util.HashMap;
import java.util.Map;

import com.demo.mvc.bean.User;
import com.demo.mvc.iface.IIocDemo;
import com.jplus.core.mvc.annotation.Service;
import com.jplus.core.mvc.bean.Result;

@Service("iocDemoImpl")
public class IocDemoImpl implements IIocDemo {

	private Map<Integer, User> map = new HashMap<>();

	@Override
	public Result addUser(User user) {
		map.put(user.getId(), user);
		return new Result().OK().DATA("新增成功");
	}

	@Override
	public Result getUser(int id) {
		if (map.containsKey(id))
			return new Result().OK().DATA(map.get(id));
		else
			return new Result().FAIL().DATA("数据不存在");
	}
}
